local AwardLayer = class("AwardLayer", require "widget/BaseUI")
 
function AwardLayer.show()
    print("============AwardLayer.show===============")
 
    local win = AwardLayer.new()

    local data = getWndInitParamList()
    data.isRemoveResource = false
    data.imgTitle = nil
    data.bgImage = nil
    data.isShowCover = false,

    win:init(data)
    win:showWindow()

    return win

end

function AwardLayer:ctor() 
    AwardLayer.super:ctor();
end


function AwardLayer:init(data)
    self:initWithParas(data)
    
    self.m_Json = ccs.GUIReader:getInstance():widgetFromJsonFile("image/ui/Json/LayerReward.json")
    self:setContentSize(self.m_Json:getContentSize())
    self.m_Json:setPositionX(-self.m_Json:getContentSize().width/2)
    self.m_Json:setPositionY(-self.m_Json:getContentSize().height/2)
    self:addChild(self.m_Json)
    
    self.m_LabelTitle = self.m_Json:getChildByName("Label_Gfhd")  --官方活动
    self.m_LabelAwardNext = self.m_Json:getChildByName("Label_AwardNext") 
    self.m_LabelPlaygame = self.m_Json:getChildByName("Label_PlayLabel") 
    self.m_LabelAward = self.m_Json:getChildByName("Label_Award")  -- 奖励：X金币
    self.m_LabelLoadx = self.m_Json:getChildByName("Label_Loadx")  -- 连续登陆X天
    
    
    self.m_BtnGotohd = self.m_Json:getChildByName("bt_Gotohd")
    self.m_BtnGotohd:setTouchEnabled(true)
    self.m_BtnGotohd:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnPlayGame = self.m_Json:getChildByName("bt_PlayGame")
    self.m_BtnPlayGame:setTouchEnabled(true)
    self.m_BtnPlayGame:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    
    self.m_BtnGotoMatch = self.m_Json:getChildByName("bt_GotoBisai")
    self.m_BtnGotoMatch:setTouchEnabled(true)
    self.m_BtnGotoMatch:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnClose = self.m_Json:getChildByName("bt_Close")
    self.m_BtnClose:setTouchEnabled(true)
    self.m_BtnClose:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
 
  
end


function AwardLayer:onMenutClick(sender,eventType)
    if eventType == ccui.TouchEventType.ended then
        if sender == self.m_BtnClose then     
            print "=========AwardLayer:onMenutClick m_BtnClose======================="
            self:closeWindow()
        elseif sender == self.m_BtnGotohd then     
            print "=========AwardLayer:onMenutClick m_BtnGotohd======================="
        elseif sender == self.m_BtnPlayGame then     
            print "=========AwardLayer:onMenutClick m_BtnPlayGame======================="
        elseif sender == self.m_BtnGotoMatch then     
            print "=========AwardLayer:onMenutClick m_BtnGotoMatch======================="
        end
    end
end
 
return AwardLayer